styleSheetNN n/a   IE 4   DOM n/a

The styleSheet object represents a style sheet that may have been created as a STYLE element or imported with a LINK element or @import statement inside a STYLE element. This object is different from the STYLE object, which strictly reflects the STYLE HTML element and its attributes. The styleSheets[] collection contains one or more styleSheet objects. The only properties that the two kinds of objects have in common are the id property (only when a stylesheet object is generated via a STYLE element) and the disabled property.

 
 
Object Model Reference
IE [window.]document.styleSheets[i]
disabledNN n/a   IE 4   DOM n/a
 Read/Write
 

Whether rules in the style sheet should be applied to their selected elements. Although the corresponding DISABLED attribute does not work in Internet Explorer 4, setting the disabled property to true does, in fact, turn off the entire style sheet. During page authoring, you can create a button that toggles style sheets on and off to see how the page looks in all types of browsers.

 
Example
document.styleSheets[0].disabled = true
 
Value
Boolean value: true | false.
 
Default false
hrefNN n/a   IE 4   DOM n/a
 Read/Write
 

The URL specified by the element's HREF attribute. The destination document is an external style sheet specification.

 
Example
document.styleSheets[1].href = "altStyles.css"
 
Value
String of complete or relative URL.
 
Default None.
owningElementNN n/a   IE 4   DOM n/a
 Read-only
 

Returns a reference to the STYLE or LINK element object that defines the current styleSheet object. Each document maintains a collection of style sheets created with both the STYLE and LINK elements.

 
Example
var firstStyleID = document.styleSheets[0].owningElement.id
 
Value
Object reference.
 
Default None.
parentStyleSheetNN n/a   IE 4   DOM n/a
 Read-only
 

Returns a reference to the styleSheet (created as a LINK or STYLE element) object that imported the current style sheet.

 
Value
Element object reference.
 
Default None.
readOnlyNN n/a   IE 4   DOM n/a
 Read-only
 

Whether the style sheet can be modified under script control. Style sheets imported through a LINK element or an @import rule cannot be modified, so they return a value of true.

 
Value
Boolean value: true | false.
 
Default false
typeNN n/a   IE 4   DOM n/a
 Read-only
 

The style sheet syntax specified by the TYPE attribute of the STYLE element. Internet Explorer 4 knows only the CSS syntax.

 
Example
if (document.styleSheets[0].type == "text/css") {
    ...
}
 
Value
String.
 
Default None.
addImport( )NN n/a   IE 4   DOM n/a

addImport(url, [index])

Adds an external style sheet specification to a styleSheet object.

 
Returned Value
Integer of the index position within the styleSheets[] collection where the style sheet was added (in case you omit the second parameter and let the browser find the end position).
 
Parameters
url A complete or relative URL to the style sheet (.css) file.
index An optional integer indicating where in the collection the new element should be placed.
addRule( )NN n/a   IE 4   DOM n/a

addRule(selector, style, [index])

Adds a new rule for a style sheet. This method offers a scripted way of adding a rule to an existing styleSheet object:

document.styleSheets[1].addRule("P B","color:red")

You may duplicate a selector that already exists in the styleSheet and, therefore, override an existing rule for the same element selector. The only prohibition is that you may not override a rule to convert a plain style rule into one that creates a positionable element. The new rule is governed by the same cascading rules as all style sheet rules (that includes the rule's source code position among other rules with the same selector). Therefore, a new rule in a styleSheet object does not supersede a style set in an element's STYLE property.

 
Returned Value
None.
 
Parameters
selector The style rule selector as a string.
style One or more style attribute:value pairs. Multiple pairs are semicolon delimited, just as they are in the regular style sheet definition.
index An optional integer indicating where in the collection the new element should be placed.
imports[ ]NN n/a   IE 4   DOM n/a

An array of all styleSheet objects that were imported into a style sheet. In a sense, a styleSheet object contains a collection of other (special) styleSheet objects. All properties and methods of the styleSheet object can be used on the individual items that are returned from the imports[] collection.

 
Syntax
document.styleSheets(i).imports(j).objectPropertyOrMethod
rules[ ]NN n/a   IE 4   DOM n/a

An array of all rules defined or imported for a styleSheet object. All properties of the rule object can be inspected for each item returned from the rules[] collection.

 
Syntax
document.styleSheets(i).rules(j).objectPropertyOrMethod